#基于jdk21
FROM registry.cn-beijing.aliyuncs.com/wanshende/maven:3.9-eclipse-temurin-17-alpine AS MAVEN_BUILD
# 作者信息
#MAINTAINER Wanshen
#jar包添加到容器
#ADD ArticleService-1.0-SNAPSHOT.jar app.jar
WORKDIR /build/
COPY article-service /build/article-service/
COPY user-service /build/user-service/
COPY feign-api /build/feign-api/
COPY common /build/common/
COPY gatewary-service /build/gatewary-service/
COPY pom.xml /build/pom.xml

WORKDIR /build
RUN mvn clean install -pl article-service -am -Dmaven.test.skip=true


FROM registry.cn-beijing.aliyuncs.com/wanshende/eclipse-temurin:17-jre
WORKDIR /app

COPY --from=MAVEN_BUILD /build/article-service/target/article-service-1.0-SNAPSHOT.jar /app/app.jar

## 设置 TZ 时区
ENV TZ=Asia/Shanghai
## 设置 JAVA_OPTS 环境变量，可通过 docker run -e "JAVA_OPTS=" 进行覆盖
ENV JAVA_OPTS="-Xms512m -Xmx512m -Djava.security.egd=file:/dev/./urandom"
ENV SPRING_PROFILES_ACTIVE=prod
## 应用参数
ENV ARGS=""

## 暴露后端项目的 80 端口
#EXPOSE 80
## 启动后端项目
CMD java ${JAVA_OPTS} -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} -jar app.jar $ARGS